home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-07-23 | 997 b | 55 lines | [TEXT/KAHL] |
- /***************************************
- * fix.cp
- * fixed-point number class implementation
- ***************************************/
-
- #include "fix.h"
- #include <math.h>
- #include <SANE.h>
-
- fix fix::result; // initialize static data member
-
- fix::operator long double()
- {
- long double result = Fix2X(n);
- return (result);
- }
-
- ostream& operator<<(ostream& os, const fix& f)
- {
- os << (double) f;
- return os;
- }
-
- istream& operator>>(istream& is, fix& f)
- {
- double temp;
-
- is >> temp;
- // Since this routine reads a floating-point number, and then converts it,
- // errors are handled in the same way as for reading floating-point numbers.
- // The iostream library includes functions for testing and reseting the error
- // state.
- if (is.good())
- f = (fix) temp;
- return is;
- }
-
- fix sin(const fix a)
- {
- fix result;
- Fract temp = FracSin(a.n);
- result.n = Frac2Fix(temp);
- return result;
- }
-
- fix cos(const fix a)
- {
- fix result;
- Fract temp = FracCos(a.n);
- result.n = Frac2Fix(temp);
- return result;
- }
-
-
-